home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / com_and3.zip / SETTIME.CMD < prev    next >
OS/2 REXX Batch file  |  1989-10-03  |  4KB  |  136 lines

  1. S0 = "CST"              ; values are: EST, CST, MST, PST, EDT, CDT, MDT, PDT
  2. ;
  3. ; ----- COM-AND set DOS clock
  4. ;
  5. ;    This script dials the US Naval Observatory and sets the DOS clock
  6. ;    with the time obtained.  NOTE: If you change this script, please
  7. ;    do not connect to the Observatory longer than absolutely required.
  8. ;    Courteous usage will most likely retain this service.
  9. ;
  10. ;    S0 should be set with your timezone (EST, CST, MST, or PST)... if
  11. ;    left blank, this script will look for an EBL variable &ZONE... if
  12. ;    that is not found, this script will ask for it.
  13. ;
  14. ;    Note that this script, as supplied, only invokes DOS's TIME command
  15. ;    to set the clock.  If you have a hardware clock, the TIME command of
  16. ;    DOS will not necessarily change the hardware clock (and thus last
  17. ;    accross a power off).
  18. ;
  19. ;    The value in S0, if supplied, establishes the timezone.  You must
  20. ;    manually decide (for now) if daylight savings is used in your area.
  21. ;
  22. ; ------------------------------------------------------------
  23. ;    Script: John Poindexter, commenced 2/89
  24. ; ------------------------------------------------------------
  25. ;
  26. ;    If the value in S0 is null, look for EBL's &ZONE
  27. ;    .. This script does not require EBL if the above is set.
  28. ;
  29. LEGEND "SETTIME v1.0"
  30. IF NULL S0        ; If value not set above
  31.    EBL S0 &ZONE     ; .. Ask EBL if it knows the zone
  32. ELSE            ; If set above
  33.    SET SUCCESS ON    ; .. Fake EBL good completion
  34.    ENDIF
  35. ;
  36. ;    If no EBL and no value, open a window and ask
  37. ;
  38. IF FAILED        ; No zone in script, and no EBL
  39.    WOPEN 10,1, 13,77 (contrast) Exit
  40.    ATSAY 11, 3 (contrast) "Enter your timezone (EST, EDT, CST, CDT, ...)"
  41.    ATSAY 12, 3 (contrast) "->"
  42.    ATSAY 13,26 (contrast) " Press ESC to exit"
  43.    ATGET 12,6  (contrast) 3 S0
  44.    WCLOSE        ; Restore screen under
  45.    IF NULL S0        ; Null entry terminates script
  46.       GOTO EXIT
  47.       ENDIF
  48.    ENDIF
  49. ;
  50. ;    Using the Zone value, look up the hour offset
  51. ;
  52. S1 = "E5C6M7P8"         ; Time zone letters and time difference from GMT.
  53. FIND S1 S0(0:0) N0    ; Case insensitive table lookup
  54. IF NOT FOUND        ; Unknown zone character
  55.    MESSAGE "^M^JYou need to include your time zone in S1 in script.^M^J"
  56.    EXIT
  57.    ENDIF
  58. ;
  59. ;    COmpute the hour offset (allowing for DAYLIGHT Savings)
  60. ;
  61. S1 = S1(N0+1:N0+1)    ; Take hour offset from table
  62. ATOI S1 N0        ; COnvert to binary (w/o error message)
  63. IF FIND S0 "D"          ; Look for daylight savings time
  64.    N0 = N0 - 1        ; Adjust for daylight savings
  65.    ENDIF
  66. ;
  67. ;    Set-up to dial the Naval Observatory
  68. ;
  69. SET FLAG(0) OFF     ; Flag indicates wrap to previous day
  70. ON ESCAPE GOSUB UNAVAILABLE
  71.  
  72. SET BAUD 1200        ; Set parms for USNO (1200,n,8,1)
  73. SET PARITY NONE     ; ..
  74. SET DATA 8        ; ..
  75. SET STOP 1        ; ..
  76. SET MDEL 30        ; Slow it down
  77. ;
  78. ;    Dial the Naval Observatory
  79. ;
  80.    N99 = 1
  81. LOOP:
  82.    LEGEND "SETTIME v1.0 dialing attempt #"*N99
  83.    TRANSMIT "_MESCa"&"!"; Wake up the modem
  84.    PAUSE 1
  85.    TRANSMIT "_DPREf"&"1-202-653-0351"&"_DSUFf"&""  ; Dialing command
  86.  
  87.    WAITFOR  "_MCONn"&"" 45 ; Remember to trim trailing blanks
  88.    IF NOT WAITFOR    ; DIAL failed
  89.       TRANSMIT "_MESCa"&"!"
  90.       TRANSMIT "_MHANg"&""
  91.       INC N99        ; COunt the try
  92.       GOTO LOOP
  93.       ENDIF
  94. ;
  95. ;    Read the UTC
  96. ;
  97. GET_TIME:
  98.    WAITFOR "*" 30
  99.    RGET S0
  100.    RGET S0
  101.    MESSAGE S0
  102.    IF NOT FIND S0(17:19) "UTC"
  103.       GOTO GET_TIME
  104.       ENDIF
  105. ;
  106. ;    Extract the time from the message
  107. ;
  108. ATOI S0(10:11) N1    ; Extract hour #
  109. IF LT N1 N0        ; Test for negative after adjust
  110.    N1 = N1 + 24     ; Ensure positive hour number after adjust
  111.    SET FLAG(0) ON    ; .. and flag the fact
  112.    ENDIF
  113. ;
  114. ;    And give the TIME to DOS
  115. ;
  116. TIME S3 1        ; Save current clock
  117. N1 = N1 - N0        ; Adjust for timezone
  118. S1 = "TIME "*N1&":"&S0(12:13)&":"&S0(14:15)
  119. DOS S1            ; Tell DOS to set the clock
  120. MESSAGE S1        ; Display on screen too
  121. CLOG "* SETTIME clock change from:" *S3*" to "*S1(5:79)
  122. HANGUP
  123. EXIT
  124. ;
  125. ;    Failed DIAL
  126. ;
  127. UNAVAILABLE:
  128.    HANGUP
  129.    MESSAGE "^M^JUnable to reach the Naval Observatory.^M^J"
  130.    EXIT
  131. ;
  132. ;    General exit (modem not connected yet)
  133. ;
  134. EXIT:
  135.    EXIT
  136.